var createdNamemmk=""
var createdBymmk=""
var createdTimeml=""
var cardata=""
var platformcc=""
var pinjgthaicc=""
//渲染表格
var coner=9//当前列表条数
var listHtml=''
for(var i=1; i<coner; i++){
    listHtml+=''
        +'<tr>'
        +'<td>'+Number(i)+'</td>'
        +'<td>'
        +'<input type="text" id="sorts'+i+'" name="s1" class="input-text" value="" autocomplete="off"  oninput="checkInput('+i+')" maxlength="1" onafterpaste="this.value=this.value.replace(/[^\d]/g,) ">'
        +'</td>'
        +'<td style="position: absolute">'
        +'<input type="text" class="input-text" value="" name="brandne3" id="brandname'+i+'" oninput="pinpai('+i+')" onclick="pinpaiii('+i+')" onkeyup ="pinpai('+i+')" autocomplete="off">'
        +'<input type="text" class="input-text" value="" id="brandnamett'+i+'"  style="display: none">'
        +'<ul class="relation radius guanlian" id="tuan'+i+'" style="margin-top: 0px;z-index: 1">'
        +'<li>无数据</li>'
        +'</ul>'
        +'</td>'
        +'<td id="uu'+i+'">'
        +'<img id="licencepicpath'+i+'" style="width: 95px;height: 25px;" src="">'
        +'</td>'
        +'<td>'
        +'<input type="file" id="file'+i+'" name="image" onchange="changImg(event,'+i+')" style="display: none"><a onclick="addBtn(this,'+i+')" id="uploads'+i+'" style="margin-left: 20px">上传</a>&nbsp;&nbsp;'
        +'<a id="deletes'+i+'" onclick="deletes('+i+')">删除</a>'
        +'</td>'
        +'</tr>'
    $('#shunlist').html(listHtml)

}
//input框判断
function checkInput(val) {
    var text = $("#sorts"+val).val()
    if(isNaN(text)){
        $.Huimodalalert('请输入数字！',2000);
        $("#sorts"+val).val("")
    }
    if(text>=9){
        $.Huimodalalert('请输入1-8数字！',2000);
        $("#sorts"+val).val("")

    }
    if(text==0){
        $.Huimodalalert('请输入1-8数字！',2000);
        $("#sorts"+val).val("")

    }
}
//初始化

var categoryid= getQueryString('categoryid')
var displayContents= decodeURI(getQueryString('displayContent'))
var frontCategoryIds= getQueryString('frontCategoryId')

//编辑详细
categoryedit();
function categoryedit() {
    //初始化 省
    $.ajax({
            type: "post",
            url: root.sroreinter.selectCatgoryBrandLogoAsId,
            cache: false,  //禁用缓存
            async:false,
            dataType: "json",
            data: {
                id: categoryid
            },
            success: function (data) {
                cardata = data
                createdNamemmk = data.data.categoryBrandLogo.createdName
                createdBymmk = data.data.categoryBrandLogo.createdBy
                createdTimeml = data.data.categoryBrandLogo.createdTime
                platformcc=data.data.categoryBrandLogo.platform
                pinjgthaicc=data.data.categoryBrandLogo.warehouseCode
                $("#title").val(data.data.categoryBrandLogo.title)
                $("#pingtai").val(data.data.categoryBrandLogo.platform)
                var warehouses=JSON.parse(sessionStorage.getItem("warehouses"))
                for(var i=0;i<warehouses.data.length;i++){
                if(warehouses.data[i].warehouseName=='北京仓'){
                    $("#pinjgthai").append("<option value=" + warehouses.data[i].warehouseCode + " selected>" + warehouses.data[i].warehouseName + "</option>")
                }else {
                    $("#pinjgthai").append("<option value=" + warehouses.data[i].warehouseCode + ">" + warehouses.data[i].warehouseName + "</option>")
                }

            }
                $("#pinjgthai").val(data.data.categoryBrandLogo.warehouseCode)
               /* $("#geta option:selected").html(displayContents)*/
                $("#geta").val(frontCategoryIds)
                $("#logmin").val(data.data.categoryBrandLogo.releaseTime)
                var kk = $("#title").val()
                var ss = kk.replace(/[\u0391-\uFFE5]/g, "aa").length;
                $("#textSpan").html(ss)
                if (data.data.categoryBrandMarge == null || data.data.categoryBrandMarge == "") {
                    $("#licencepicpath1").remove();
                    $("#licencepicpath2").remove();
                    $("#licencepicpath3").remove();
                    $("#licencepicpath4").remove();
                    $("#licencepicpath5").remove();
                    $("#licencepicpath6").remove();
                    $("#licencepicpath7").remove();
                    $("#licencepicpath8").remove();
                    $("#deletes").attr("style", "opacity: 0.2");
                    $('#deletes').removeAttr('onclick');
                    $("#deletes2").attr("style", "opacity: 0.2");
                    $('#deletes2').removeAttr('onclick');
                    $("#deletes3").attr("style", "opacity: 0.2");
                    $('#deletes3').removeAttr('onclick');
                    $("#deletes4").attr("style", "opacity: 0.2");
                    $('#deletes4').removeAttr('onclick');
                    $("#deletes5").attr("style", "opacity: 0.2");
                    $('#deletes5').removeAttr('onclick');
                    $("#deletes6").attr("style", "opacity: 0.2");
                    $('#deletes6').removeAttr('onclick');
                    $("#deletes7").attr("style", "opacity: 0.2");
                    $('#deletes7').removeAttr('onclick');
                    $("#deletes8").attr("style", "opacity: 0.2");
                    $('#deletes8').removeAttr('onclick');
                }
                for (var i = 0; i < data.data.categoryBrandMarge.length; i++) {
                    if (data.data.categoryBrandMarge.length == 1) {
                        console.log("1111111111111")
                        $("#sorts1").val(data.data.categoryBrandMarge[0].sequence)
                        $("#brandname1").val(data.data.categoryBrandMarge[0].brandName)
                        $("#brandname1").text(data.data.categoryBrandMarge[0].brandId)
                        if (data.data.categoryBrandMarge[0].brandPictureUrl != "" || data.data.categoryBrandMarge[0].brandPictureUrl != undefined) {
                            $("#uu1").html("<img id='licencepicpath1' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[0].brandPictureUrl + "'>")
                            $("#uploads1").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads1').removeAttr('onclick');
                            $('#deletes1').attr('onclick', 'deletes(1)');
                            $("#deletes1").removeAttr("style");
                        } else {
                            $("#licencepicpath1").remove();
                            $("#deletes1").attr("style", "opacity: 0.2");
                            $('#deletes1').removeAttr('onclick');
                            $('#uploads1').removeAttr("style");
                            $('#uploads1').attr("onclick", "addBtn(this,1)");
                            $('#uploads1').attr("style", "margin-left: 20px");
                        }


                        $("#licencepicpath2").remove();
                        $("#licencepicpath3").remove();
                        $("#licencepicpath4").remove();
                        $("#licencepicpath5").remove();
                        $("#licencepicpath6").remove();
                        $("#licencepicpath7").remove();
                        $("#licencepicpath8").remove();
                        $("#deletes2").attr("style", "opacity: 0.2");
                        $('#deletes2').removeAttr('onclick');
                        $("#deletes3").attr("style", "opacity: 0.2");
                        $('#deletes3').removeAttr('onclick');
                        $("#deletes4").attr("style", "opacity: 0.2");
                        $('#deletes4').removeAttr('onclick');
                        $("#deletes5").attr("style", "opacity: 0.2");
                        $('#deletes5').removeAttr('onclick');
                        $("#deletes6").attr("style", "opacity: 0.2");
                        $('#deletes6').removeAttr('onclick');
                        $("#deletes7").attr("style", "opacity: 0.2");
                        $('#deletes7').removeAttr('onclick');
                        $("#deletes8").attr("style", "opacity: 0.2");
                        $('#deletes8').removeAttr('onclick');

                    } else if (data.data.categoryBrandMarge.length == 2) {
                        console.log("22222222222222222")
                        $("#sorts1").val(data.data.categoryBrandMarge[0].sequence)
                        $("#brandname1").val(data.data.categoryBrandMarge[0].brandName)
                        $("#brandname1").text(data.data.categoryBrandMarge[0].brandId)
                        if (data.data.categoryBrandMarge[0].brandPictureUrl != "" || data.data.categoryBrandMarge[0].brandPictureUrl != undefined) {
                            $("#uu1").html("<img id='licencepicpath1' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[0].brandPictureUrl + "'>")
                            $("#uploads1").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads1').removeAttr('onclick');
                            $('#deletes1').attr('onclick', 'deletes(1)');
                            $("#deletes1").removeAttr("style");
                        } else {
                            $("#licencepicpath1").remove();
                            $("#deletes1").attr("style", "opacity: 0.2");
                            $('#deletes1').removeAttr('onclick');
                            $('#uploads1').removeAttr("style");
                            $('#uploads1').attr("onclick", "addBtn(this,1)");
                            $('#uploads1').attr("style", "margin-left: 20px");
                        }


                        $("#sorts2").val(data.data.categoryBrandMarge[1].sequence)
                        $("#brandname2").val(data.data.categoryBrandMarge[1].brandName)
                        $("#brandname2").text(data.data.categoryBrandMarge[1].brandId)
                        if (data.data.categoryBrandMarge[1].brandPictureUrl != "" || data.data.categoryBrandMarge[1].brandPictureUrl != undefined) {

                            $("#uu2").html("<img id='licencepicpath2' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[1].brandPictureUrl + "'>")
                            $("#uploads2").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads2').removeAttr('onclick');
                            $('#deletes2').attr('onclick', 'deletes(2)');
                            $("#deletes2").removeAttr("style");
                        } else {
                            $("#licencepicpath2").remove();
                            $("#deletes2").attr("style", "opacity: 0.2");
                            $('#deletes2').removeAttr('onclick');
                            $('#uploads2').removeAttr("style");
                            $('#uploads2').attr("onclick", "addBtn(this,1)");
                            $('#uploads2').attr("style", "margin-left: 20px");
                        }

                        $("#licencepicpath3").remove();
                        $("#licencepicpath4").remove();
                        $("#licencepicpath5").remove();
                        $("#licencepicpath6").remove();
                        $("#licencepicpath7").remove();
                        $("#licencepicpath8").remove();
                        $("#deletes3").attr("style", "opacity: 0.2");
                        $('#deletes3').removeAttr('onclick');
                        $("#deletes4").attr("style", "opacity: 0.2");
                        $('#deletes4').removeAttr('onclick');
                        $("#deletes5").attr("style", "opacity: 0.2");
                        $('#deletes5').removeAttr('onclick');
                        $("#deletes6").attr("style", "opacity: 0.2");
                        $('#deletes6').removeAttr('onclick');
                        $("#deletes7").attr("style", "opacity: 0.2");
                        $('#deletes7').removeAttr('onclick');
                        $("#deletes8").attr("style", "opacity: 0.2");
                        $('#deletes8').removeAttr('onclick');
                    } else if (data.data.categoryBrandMarge.length == 3) {

                        console.log("333333333333333333333333333")
                        $("#sorts1").val(data.data.categoryBrandMarge[0].sequence)
                        $("#brandname1").val(data.data.categoryBrandMarge[0].brandName)
                        $("#brandname1").text(data.data.categoryBrandMarge[0].brandId)
                        if (data.data.categoryBrandMarge[0].brandPictureUrl != "" || data.data.categoryBrandMarge[0].brandPictureUrl != undefined) {
                            $("#uu1").html("<img id='licencepicpath1' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[0].brandPictureUrl + "'>")
                            $("#uploads1").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads1').removeAttr('onclick');
                            $('#deletes1').attr('onclick', 'deletes(1)');
                            $("#deletes1").removeAttr("style");
                        } else {
                            $("#licencepicpath1").remove();
                            $("#deletes1").attr("style", "opacity: 0.2");
                            $('#deletes1').removeAttr('onclick');
                            $('#uploads1').removeAttr("style");
                            $('#uploads1').attr("onclick", "addBtn(this,1)");
                            $('#uploads1').attr("style", "margin-left: 20px");
                        }

                        $("#sorts2").val(data.data.categoryBrandMarge[1].sequence)
                        $("#brandname2").val(data.data.categoryBrandMarge[1].brandName)
                        $("#brandname2").text(data.data.categoryBrandMarge[1].brandId)
                        if (data.data.categoryBrandMarge[1].brandPictureUrl != "" || data.data.categoryBrandMarge[1].brandPictureUrl != undefined) {

                            $("#uu2").html("<img id='licencepicpath2' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[1].brandPictureUrl + "'>")
                            $("#uploads2").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads2').removeAttr('onclick');
                            $('#deletes2').attr('onclick', 'deletes(2)');
                            $("#deletes2").removeAttr("style");
                        } else {
                            $("#licencepicpath2").remove();
                            $("#deletes2").attr("style", "opacity: 0.2");
                            $('#deletes2').removeAttr('onclick');
                            $('#uploads2').removeAttr("style");
                            $('#uploads2').attr("onclick", "addBtn(this,1)");
                            $('#uploads2').attr("style", "margin-left: 20px");
                        }

                        $("#sorts3").val(data.data.categoryBrandMarge[2].sequence)
                        $("#brandname3").val(data.data.categoryBrandMarge[2].brandName)
                        $("#brandname3").text(data.data.categoryBrandMarge[2].brandId)

                        if (data.data.categoryBrandMarge[2].brandPictureUrl != "" || data.data.categoryBrandMarge[2].brandPictureUrl != undefined) {
                            $("#uu3").html("<img id='licencepicpath3' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[2].brandPictureUrl + "'>")
                            $("#uploads3").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads3').removeAttr('onclick');
                            $('#deletes3').attr('onclick', 'deletes(3)');
                            $("#deletes3").removeAttr("style");
                        } else {
                            $("#licencepicpath3").remove();
                            $("#deletes3").attr("style", "opacity: 0.2");
                            $('#deletes3').removeAttr('onclick');
                            $('#uploads3').removeAttr("style");
                            $('#uploads3').attr("onclick", "addBtn(this,1)");
                            $('#uploads3').attr("style", "margin-left: 20px");
                        }

                        $("#licencepicpath4").remove();
                        $("#licencepicpath5").remove();
                        $("#licencepicpath6").remove();
                        $("#licencepicpath7").remove();
                        $("#licencepicpath8").remove();
                        $("#deletes4").attr("style", "opacity: 0.2");
                        $('#deletes4').removeAttr('onclick');
                        $("#deletes5").attr("style", "opacity: 0.2");
                        $('#deletes5').removeAttr('onclick');
                        $("#deletes6").attr("style", "opacity: 0.2");
                        $('#deletes6').removeAttr('onclick');
                        $("#deletes7").attr("style", "opacity: 0.2");
                        $('#deletes7').removeAttr('onclick');
                        $("#deletes8").attr("style", "opacity: 0.2");
                        $('#deletes8').removeAttr('onclick');
                    } else if (data.data.categoryBrandMarge.length == 4) {

                        console.log("4444444444444444444444444444444")
                        $("#sorts1").val(data.data.categoryBrandMarge[0].sequence)
                        $("#brandname1").val(data.data.categoryBrandMarge[0].brandName)
                        $("#brandname1").text(data.data.categoryBrandMarge[0].brandId)
                        if (data.data.categoryBrandMarge[0].brandPictureUrl != "" || data.data.categoryBrandMarge[0].brandPictureUrl != undefined) {
                            $("#uu1").html("<img id='licencepicpath1' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[0].brandPictureUrl + "'>")
                            $("#uploads1").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads1').removeAttr('onclick');
                            $('#deletes1').attr('onclick', 'deletes(1)');
                            $("#deletes1").removeAttr("style");
                        } else {
                            $("#licencepicpath1").remove();
                            $("#deletes1").attr("style", "opacity: 0.2");
                            $('#deletes1').removeAttr('onclick');
                            $('#uploads1').removeAttr("style");
                            $('#uploads1').attr("onclick", "addBtn(this,1)");
                            $('#uploads1').attr("style", "margin-left: 20px");
                        }

                        $("#sorts2").val(data.data.categoryBrandMarge[1].sequence)
                        $("#brandname2").val(data.data.categoryBrandMarge[1].brandName)
                        $("#brandname2").text(data.data.categoryBrandMarge[1].brandId)
                        if (data.data.categoryBrandMarge[1].brandPictureUrl != "" || data.data.categoryBrandMarge[1].brandPictureUrl != undefined) {

                            $("#uu2").html("<img id='licencepicpath2' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[1].brandPictureUrl + "'>")
                            $("#uploads2").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads2').removeAttr('onclick');
                            $('#deletes2').attr('onclick', 'deletes(2)');
                            $("#deletes2").removeAttr("style");
                        } else {
                            $("#licencepicpath2").remove();
                            $("#deletes2").attr("style", "opacity: 0.2");
                            $('#deletes2').removeAttr('onclick');
                            $('#uploads2').removeAttr("style");
                            $('#uploads2').attr("onclick", "addBtn(this,1)");
                            $('#uploads2').attr("style", "margin-left: 20px");
                        }

                        $("#sorts3").val(data.data.categoryBrandMarge[2].sequence)
                        $("#brandname3").val(data.data.categoryBrandMarge[2].brandName)
                        $("#brandname3").text(data.data.categoryBrandMarge[2].brandId)

                        if (data.data.categoryBrandMarge[2].brandPictureUrl != "" || data.data.categoryBrandMarge[2].brandPictureUrl != undefined) {
                            $("#uu3").html("<img id='licencepicpath3' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[2].brandPictureUrl + "'>")
                            $("#uploads3").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads3').removeAttr('onclick');
                            $('#deletes3').attr('onclick', 'deletes(3)');
                            $("#deletes3").removeAttr("style");
                        } else {
                            $("#licencepicpath3").remove();
                            $("#deletes3").attr("style", "opacity: 0.2");
                            $('#deletes3').removeAttr('onclick');
                            $('#uploads3').removeAttr("style");
                            $('#uploads3').attr("onclick", "addBtn(this,1)");
                            $('#uploads3').attr("style", "margin-left: 20px");
                        }

                        $("#sorts4").val(data.data.categoryBrandMarge[3].sequence)
                        $("#brandname4").val(data.data.categoryBrandMarge[3].brandName)
                        $("#brandname4").text(data.data.categoryBrandMarge[3].brandId)
                        if (data.data.categoryBrandMarge[3].brandPictureUrl != "" || data.data.categoryBrandMarge[3].brandPictureUrl != undefined) {

                            $("#uu4").html("<img id='licencepicpath4' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[3].brandPictureUrl + "'>")
                            $("#uploads4").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads4').removeAttr('onclick');
                            $('#deletes4').attr('onclick', 'deletes(4)');
                            $("#deletes4").removeAttr("style");
                        } else {
                            $("#licencepicpath4").remove();
                            $("#deletes4").attr("style", "opacity: 0.2");
                            $('#deletes4').removeAttr('onclick');
                            $('#uploads4').removeAttr("style");
                            $('#uploads4').attr("onclick", "addBtn(this,1)");
                            $('#uploads4').attr("style", "margin-left: 20px");
                        }

                        $("#licencepicpath5").remove();
                        $("#licencepicpath6").remove();
                        $("#licencepicpath7").remove();
                        $("#licencepicpath8").remove();
                        $("#deletes5").attr("style", "opacity: 0.2");
                        $('#deletes5').removeAttr('onclick');
                        $("#deletes6").attr("style", "opacity: 0.2");
                        $('#deletes6').removeAttr('onclick');
                        $("#deletes7").attr("style", "opacity: 0.2");
                        $('#deletes7').removeAttr('onclick');
                        $("#deletes8").attr("style", "opacity: 0.2");
                        $('#deletes8').removeAttr('onclick');
                    } else if (data.data.categoryBrandMarge.length == 5) {

                        console.log("55555555555555555555555")
                        $("#sorts1").val(data.data.categoryBrandMarge[0].sequence)
                        $("#brandname1").val(data.data.categoryBrandMarge[0].brandName)
                        $("#brandname1").text(data.data.categoryBrandMarge[0].brandId)
                        if (data.data.categoryBrandMarge[0].brandPictureUrl != "" || data.data.categoryBrandMarge[0].brandPictureUrl != undefined) {
                            $("#uu1").html("<img id='licencepicpath1' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[0].brandPictureUrl + "'>")
                            $("#uploads1").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads1').removeAttr('onclick');
                            $('#deletes1').attr('onclick', 'deletes(1)');
                            $("#deletes1").removeAttr("style");
                        } else {
                            $("#licencepicpath1").remove();
                            $("#deletes1").attr("style", "opacity: 0.2");
                            $('#deletes1').removeAttr('onclick');
                            $('#uploads1').removeAttr("style");
                            $('#uploads1').attr("onclick", "addBtn(this,1)");
                            $('#uploads1').attr("style", "margin-left: 20px");
                        }

                        $("#sorts2").val(data.data.categoryBrandMarge[1].sequence)
                        $("#brandname2").val(data.data.categoryBrandMarge[1].brandName)
                        $("#brandname2").text(data.data.categoryBrandMarge[1].brandId)
                        if (data.data.categoryBrandMarge[1].brandPictureUrl != "" || data.data.categoryBrandMarge[1].brandPictureUrl != undefined) {

                            $("#uu2").html("<img id='licencepicpath2' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[1].brandPictureUrl + "'>")
                            $("#uploads2").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads2').removeAttr('onclick');
                            $('#deletes2').attr('onclick', 'deletes(2)');
                            $("#deletes2").removeAttr("style");
                        } else {
                            $("#licencepicpath2").remove();
                            $("#deletes2").attr("style", "opacity: 0.2");
                            $('#deletes2').removeAttr('onclick');
                            $('#uploads2').removeAttr("style");
                            $('#uploads2').attr("onclick", "addBtn(this,1)");
                            $('#uploads2').attr("style", "margin-left: 20px");
                        }

                        $("#sorts3").val(data.data.categoryBrandMarge[2].sequence)
                        $("#brandname3").val(data.data.categoryBrandMarge[2].brandName)
                        $("#brandname3").text(data.data.categoryBrandMarge[2].brandId)

                        if (data.data.categoryBrandMarge[2].brandPictureUrl != "" || data.data.categoryBrandMarge[2].brandPictureUrl != undefined) {
                            $("#uu3").html("<img id='licencepicpath3' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[2].brandPictureUrl + "'>")
                            $("#uploads3").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads3').removeAttr('onclick');
                            $('#deletes3').attr('onclick', 'deletes(3)');
                            $("#deletes3").removeAttr("style");
                        } else {
                            $("#licencepicpath3").remove();
                            $("#deletes3").attr("style", "opacity: 0.2");
                            $('#deletes3').removeAttr('onclick');
                            $('#uploads3').removeAttr("style");
                            $('#uploads3').attr("onclick", "addBtn(this,1)");
                            $('#uploads3').attr("style", "margin-left: 20px");
                        }

                        $("#sorts4").val(data.data.categoryBrandMarge[3].sequence)
                        $("#brandname4").val(data.data.categoryBrandMarge[3].brandName)
                        $("#brandname4").text(data.data.categoryBrandMarge[3].brandId)
                        if (data.data.categoryBrandMarge[3].brandPictureUrl != "" || data.data.categoryBrandMarge[3].brandPictureUrl != undefined) {

                            $("#uu4").html("<img id='licencepicpath4' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[3].brandPictureUrl + "'>")
                            $("#uploads4").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads4').removeAttr('onclick');
                            $('#deletes4').attr('onclick', 'deletes(4)');
                            $("#deletes4").removeAttr("style");
                        } else {
                            $("#licencepicpath4").remove();
                            $("#deletes4").attr("style", "opacity: 0.2");
                            $('#deletes4').removeAttr('onclick');
                            $('#uploads4').removeAttr("style");
                            $('#uploads4').attr("onclick", "addBtn(this,1)");
                            $('#uploads4').attr("style", "margin-left: 20px");
                        }


                        $("#sorts5").val(data.data.categoryBrandMarge[4].sequence)
                        $("#brandname5").val(data.data.categoryBrandMarge[4].brandName)
                        $("#brandname5").text(data.data.categoryBrandMarge[4].brandId)
                        if (data.data.categoryBrandMarge[4].brandPictureUrl != "" || data.data.categoryBrandMarge[4].brandPictureUrl != undefined) {

                            $("#uu5").html("<img id='licencepicpath5' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[4].brandPictureUrl + "'>")
                            $("#uploads5").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads5').removeAttr('onclick');
                            $('#deletes5').attr('onclick', 'deletes(5)');
                            $("#deletes5").removeAttr("style");
                        } else {
                            $("#licencepicpath5").remove();
                            $("#deletes5").attr("style", "opacity: 0.2");
                            $('#deletes5').removeAttr('onclick');
                            $('#uploads5').removeAttr("style");
                            $('#uploads5').attr("onclick", "addBtn(this,1)");
                            $('#uploads5').attr("style", "margin-left: 20px");
                        }

                        $("#licencepicpath6").remove();
                        $("#licencepicpath7").remove();
                        $("#licencepicpath8").remove();
                        $("#deletes6").attr("style", "opacity: 0.2");
                        $('#deletes6').removeAttr('onclick');
                        $("#deletes7").attr("style", "opacity: 0.2");
                        $('#deletes7').removeAttr('onclick');
                        $("#deletes8").attr("style", "opacity: 0.2");
                        $('#deletes8').removeAttr('onclick');
                    } else if (data.data.categoryBrandMarge.length == 6) {

                        console.log("666666666666666666666666")
                        $("#sorts1").val(data.data.categoryBrandMarge[0].sequence)
                        $("#brandname1").val(data.data.categoryBrandMarge[0].brandName)
                        $("#brandname1").text(data.data.categoryBrandMarge[0].brandId)
                        if (data.data.categoryBrandMarge[0].brandPictureUrl != "" || data.data.categoryBrandMarge[0].brandPictureUrl != undefined) {
                            $("#uu1").html("<img id='licencepicpath1' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[0].brandPictureUrl + "'>")
                            $("#uploads1").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads1').removeAttr('onclick');
                            $('#deletes1').attr('onclick', 'deletes(1)');
                            $("#deletes1").removeAttr("style");
                        } else {
                            $("#licencepicpath1").remove();
                            $("#deletes1").attr("style", "opacity: 0.2");
                            $('#deletes1').removeAttr('onclick');
                            $('#uploads1').removeAttr("style");
                            $('#uploads1').attr("onclick", "addBtn(this,1)");
                            $('#uploads1').attr("style", "margin-left: 20px");
                        }

                        $("#sorts2").val(data.data.categoryBrandMarge[1].sequence)
                        $("#brandname2").val(data.data.categoryBrandMarge[1].brandName)
                        $("#brandname2").text(data.data.categoryBrandMarge[1].brandId)
                        if (data.data.categoryBrandMarge[1].brandPictureUrl != "" || data.data.categoryBrandMarge[1].brandPictureUrl != undefined) {

                            $("#uu2").html("<img id='licencepicpath2' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[1].brandPictureUrl + "'>")
                            $("#uploads2").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads2').removeAttr('onclick');
                            $('#deletes2').attr('onclick', 'deletes(2)');
                            $("#deletes2").removeAttr("style");
                        } else {
                            $("#licencepicpath2").remove();
                            $("#deletes2").attr("style", "opacity: 0.2");
                            $('#deletes2').removeAttr('onclick');
                            $('#uploads2').removeAttr("style");
                            $('#uploads2').attr("onclick", "addBtn(this,1)");
                            $('#uploads2').attr("style", "margin-left: 20px");
                        }

                        $("#sorts3").val(data.data.categoryBrandMarge[2].sequence)
                        $("#brandname3").val(data.data.categoryBrandMarge[2].brandName)
                        $("#brandname3").text(data.data.categoryBrandMarge[2].brandId)

                        if (data.data.categoryBrandMarge[2].brandPictureUrl != "" || data.data.categoryBrandMarge[2].brandPictureUrl != undefined) {
                            $("#uu3").html("<img id='licencepicpath3' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[2].brandPictureUrl + "'>")
                            $("#uploads3").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads3').removeAttr('onclick');
                            $('#deletes3').attr('onclick', 'deletes(3)');
                            $("#deletes3").removeAttr("style");
                        } else {
                            $("#licencepicpath3").remove();
                            $("#deletes3").attr("style", "opacity: 0.2");
                            $('#deletes3').removeAttr('onclick');
                            $('#uploads3').removeAttr("style");
                            $('#uploads3').attr("onclick", "addBtn(this,1)");
                            $('#uploads3').attr("style", "margin-left: 20px");
                        }

                        $("#sorts4").val(data.data.categoryBrandMarge[3].sequence)
                        $("#brandname4").val(data.data.categoryBrandMarge[3].brandName)
                        $("#brandname4").text(data.data.categoryBrandMarge[3].brandId)
                        if (data.data.categoryBrandMarge[3].brandPictureUrl != "" || data.data.categoryBrandMarge[3].brandPictureUrl != undefined) {

                            $("#uu4").html("<img id='licencepicpath4' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[3].brandPictureUrl + "'>")
                            $("#uploads4").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads4').removeAttr('onclick');
                            $('#deletes4').attr('onclick', 'deletes(4)');
                            $("#deletes4").removeAttr("style");
                        } else {
                            $("#licencepicpath4").remove();
                            $("#deletes4").attr("style", "opacity: 0.2");
                            $('#deletes4').removeAttr('onclick');
                            $('#uploads4').removeAttr("style");
                            $('#uploads4').attr("onclick", "addBtn(this,1)");
                            $('#uploads4').attr("style", "margin-left: 20px");
                        }


                        $("#sorts5").val(data.data.categoryBrandMarge[4].sequence)
                        $("#brandname5").val(data.data.categoryBrandMarge[4].brandName)
                        $("#brandname5").text(data.data.categoryBrandMarge[4].brandId)
                        if (data.data.categoryBrandMarge[4].brandPictureUrl != "" || data.data.categoryBrandMarge[4].brandPictureUrl != undefined) {

                            $("#uu5").html("<img id='licencepicpath5' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[4].brandPictureUrl + "'>")
                            $("#uploads5").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads5').removeAttr('onclick');
                            $('#deletes5').attr('onclick', 'deletes(5)');
                            $("#deletes5").removeAttr("style");
                        } else {
                            $("#licencepicpath5").remove();
                            $("#deletes5").attr("style", "opacity: 0.2");
                            $('#deletes5').removeAttr('onclick');
                            $('#uploads5').removeAttr("style");
                            $('#uploads5').attr("onclick", "addBtn(this,1)");
                            $('#uploads5').attr("style", "margin-left: 20px");
                        }

                        $("#sorts6").val(data.data.categoryBrandMarge[5].sequence)
                        $("#brandname6").val(data.data.categoryBrandMarge[5].brandName)
                        $("#brandname6").text(data.data.categoryBrandMarge[5].brandId)
                        if (data.data.categoryBrandMarge[5].brandPictureUrl != "" || data.data.categoryBrandMarge[5].brandPictureUrl != undefined) {

                            $("#uu6").html("<img id='licencepicpath6' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[5].brandPictureUrl + "'>")
                            $("#uploads6").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads6').removeAttr('onclick');
                            $('#deletes6').attr('onclick', 'deletes(6)');
                            $("#deletes6").removeAttr("style");
                        } else {
                            $("#licencepicpath6").remove();
                            $("#deletes6").attr("style", "opacity: 0.2");
                            $('#deletes6').removeAttr('onclick');
                            $('#uploads6').removeAttr("style");
                            $('#uploads6').attr("onclick", "addBtn(this,1)");
                            $('#uploads6').attr("style", "margin-left: 20px");
                        }
                        $("#licencepicpath7").remove();
                        $("#licencepicpath8").remove();
                        $("#deletes7").attr("style", "opacity: 0.2");
                        $('#deletes7').removeAttr('onclick');
                        $("#deletes8").attr("style", "opacity: 0.2");
                        $('#deletes8').removeAttr('onclick');
                    } else if (data.data.categoryBrandMarge.length == 7) {
                        console.log("777777777777777777")
                        $("#sorts1").val(data.data.categoryBrandMarge[0].sequence)
                        $("#brandname1").val(data.data.categoryBrandMarge[0].brandName)
                        $("#brandname1").text(data.data.categoryBrandMarge[0].brandId)
                        if (data.data.categoryBrandMarge[0].brandPictureUrl != "" || data.data.categoryBrandMarge[0].brandPictureUrl != undefined) {
                            $("#uu1").html("<img id='licencepicpath1' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[0].brandPictureUrl + "'>")
                            $("#uploads1").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads1').removeAttr('onclick');
                            $('#deletes1').attr('onclick', 'deletes(1)');
                            $("#deletes1").removeAttr("style");
                        } else {
                            $("#licencepicpath1").remove();
                            $("#deletes1").attr("style", "opacity: 0.2");
                            $('#deletes1').removeAttr('onclick');
                            $('#uploads1').removeAttr("style");
                            $('#uploads1').attr("onclick", "addBtn(this,1)");
                            $('#uploads1').attr("style", "margin-left: 20px");
                        }

                        $("#sorts2").val(data.data.categoryBrandMarge[1].sequence)
                        $("#brandname2").val(data.data.categoryBrandMarge[1].brandName)
                        $("#brandname2").text(data.data.categoryBrandMarge[1].brandId)
                        if (data.data.categoryBrandMarge[1].brandPictureUrl != "" || data.data.categoryBrandMarge[1].brandPictureUrl != undefined) {

                            $("#uu2").html("<img id='licencepicpath2' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[1].brandPictureUrl + "'>")
                            $("#uploads2").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads2').removeAttr('onclick');
                            $('#deletes2').attr('onclick', 'deletes(2)');
                            $("#deletes2").removeAttr("style");
                        } else {
                            $("#licencepicpath2").remove();
                            $("#deletes2").attr("style", "opacity: 0.2");
                            $('#deletes2').removeAttr('onclick');
                            $('#uploads2').removeAttr("style");
                            $('#uploads2').attr("onclick", "addBtn(this,1)");
                            $('#uploads2').attr("style", "margin-left: 20px");
                        }

                        $("#sorts3").val(data.data.categoryBrandMarge[2].sequence)
                        $("#brandname3").val(data.data.categoryBrandMarge[2].brandName)
                        $("#brandname3").text(data.data.categoryBrandMarge[2].brandId)

                        if (data.data.categoryBrandMarge[2].brandPictureUrl != "" || data.data.categoryBrandMarge[2].brandPictureUrl != undefined) {
                            $("#uu3").html("<img id='licencepicpath3' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[2].brandPictureUrl + "'>")
                            $("#uploads3").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads3').removeAttr('onclick');
                            $('#deletes3').attr('onclick', 'deletes(3)');
                            $("#deletes3").removeAttr("style");
                        } else {
                            $("#licencepicpath3").remove();
                            $("#deletes3").attr("style", "opacity: 0.2");
                            $('#deletes3').removeAttr('onclick');
                            $('#uploads3').removeAttr("style");
                            $('#uploads3').attr("onclick", "addBtn(this,1)");
                            $('#uploads3').attr("style", "margin-left: 20px");
                        }

                        $("#sorts4").val(data.data.categoryBrandMarge[3].sequence)
                        $("#brandname4").val(data.data.categoryBrandMarge[3].brandName)
                        $("#brandname4").text(data.data.categoryBrandMarge[3].brandId)
                        if (data.data.categoryBrandMarge[3].brandPictureUrl != "" || data.data.categoryBrandMarge[3].brandPictureUrl != undefined) {

                            $("#uu4").html("<img id='licencepicpath4' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[3].brandPictureUrl + "'>")
                            $("#uploads4").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads4').removeAttr('onclick');
                            $('#deletes4').attr('onclick', 'deletes(4)');
                            $("#deletes4").removeAttr("style");
                        } else {
                            $("#licencepicpath4").remove();
                            $("#deletes4").attr("style", "opacity: 0.2");
                            $('#deletes4').removeAttr('onclick');
                            $('#uploads4').removeAttr("style");
                            $('#uploads4').attr("onclick", "addBtn(this,1)");
                            $('#uploads4').attr("style", "margin-left: 20px");
                        }


                        $("#sorts5").val(data.data.categoryBrandMarge[4].sequence)
                        $("#brandname5").val(data.data.categoryBrandMarge[4].brandName)
                        $("#brandname5").text(data.data.categoryBrandMarge[4].brandId)
                        if (data.data.categoryBrandMarge[4].brandPictureUrl != "" || data.data.categoryBrandMarge[4].brandPictureUrl != undefined) {

                            $("#uu5").html("<img id='licencepicpath5' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[4].brandPictureUrl + "'>")
                            $("#uploads5").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads5').removeAttr('onclick');
                            $('#deletes5').attr('onclick', 'deletes(5)');
                            $("#deletes5").removeAttr("style");
                        } else {
                            $("#licencepicpath5").remove();
                            $("#deletes5").attr("style", "opacity: 0.2");
                            $('#deletes5').removeAttr('onclick');
                            $('#uploads5').removeAttr("style");
                            $('#uploads5').attr("onclick", "addBtn(this,1)");
                            $('#uploads5').attr("style", "margin-left: 20px");
                        }

                        $("#sorts6").val(data.data.categoryBrandMarge[5].sequence)
                        $("#brandname6").val(data.data.categoryBrandMarge[5].brandName)
                        $("#brandname6").text(data.data.categoryBrandMarge[5].brandId)
                        if (data.data.categoryBrandMarge[5].brandPictureUrl != "" || data.data.categoryBrandMarge[5].brandPictureUrl != undefined) {

                            $("#uu6").html("<img id='licencepicpath6' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[5].brandPictureUrl + "'>")
                            $("#uploads6").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads6').removeAttr('onclick');
                            $('#deletes6').attr('onclick', 'deletes(6)');
                            $("#deletes6").removeAttr("style");
                        } else {
                            $("#licencepicpath6").remove();
                            $("#deletes6").attr("style", "opacity: 0.2");
                            $('#deletes6').removeAttr('onclick');
                            $('#uploads6').removeAttr("style");
                            $('#uploads6').attr("onclick", "addBtn(this,1)");
                            $('#uploads6').attr("style", "margin-left: 20px");
                        }
                        $("#sorts7").val(data.data.categoryBrandMarge[6].sequence)
                        $("#brandname7").val(data.data.categoryBrandMarge[6].brandName)
                        $("#brandname7").text(data.data.categoryBrandMarge[6].brandId)
                        if (data.data.categoryBrandMarge[6].brandPictureUrl != "" || data.data.categoryBrandMarge[6].brandPictureUrl != undefined) {

                            $("#uu7").html("<img id='licencepicpath7' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[6].brandPictureUrl + "'>")
                            $("#uploads7").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads7').removeAttr('onclick');
                            $('#deletes7').attr('onclick', 'deletes(7)');
                            $("#deletes7").removeAttr("style");
                        } else {
                            $("#licencepicpath7").remove();
                            $("#deletes7").attr("style", "opacity: 0.2");
                            $('#deletes7').removeAttr('onclick');
                            $('#uploads7').removeAttr("style");
                            $('#uploads7').attr("onclick", "addBtn(this,1)");
                            $('#uploads7').attr("style", "margin-left: 20px");
                        }
                        $("#licencepicpath8").remove();
                        $("#deletes8").attr("style", "opacity: 0.2");
                        $('#deletes8').removeAttr('onclick');
                    } else if (data.data.categoryBrandMarge.length == 8) {
                        console.log("8888888888888888888888")
                        $("#sorts1").val(data.data.categoryBrandMarge[0].sequence)
                        $("#brandname1").val(data.data.categoryBrandMarge[0].brandName)
                        $("#brandname1").text(data.data.categoryBrandMarge[0].brandId)
                        if (data.data.categoryBrandMarge[0].brandPictureUrl != "" || data.data.categoryBrandMarge[0].brandPictureUrl != undefined) {
                            $("#uu1").html("<img id='licencepicpath1' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[0].brandPictureUrl + "'>")
                            $("#uploads1").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads1').removeAttr('onclick');
                            $('#deletes1').attr('onclick', 'deletes(1)');
                            $("#deletes1").removeAttr("style");
                        } else {
                            $("#licencepicpath1").remove();
                            $("#deletes1").attr("style", "opacity: 0.2");
                            $('#deletes1').removeAttr('onclick');
                            $('#uploads1').removeAttr("style");
                            $('#uploads1').attr("onclick", "addBtn(this,1)");
                            $('#uploads1').attr("style", "margin-left: 20px");
                        }

                        $("#sorts2").val(data.data.categoryBrandMarge[1].sequence)
                        $("#brandname2").val(data.data.categoryBrandMarge[1].brandName)
                        $("#brandname2").text(data.data.categoryBrandMarge[1].brandId)
                        if (data.data.categoryBrandMarge[1].brandPictureUrl != "" || data.data.categoryBrandMarge[1].brandPictureUrl != undefined) {

                            $("#uu2").html("<img id='licencepicpath2' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[1].brandPictureUrl + "'>")
                            $("#uploads2").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads2').removeAttr('onclick');
                            $('#deletes2').attr('onclick', 'deletes(2)');
                            $("#deletes2").removeAttr("style");
                        } else {
                            $("#licencepicpath2").remove();
                            $("#deletes2").attr("style", "opacity: 0.2");
                            $('#deletes2').removeAttr('onclick');
                            $('#uploads2').removeAttr("style");
                            $('#uploads2').attr("onclick", "addBtn(this,1)");
                            $('#uploads2').attr("style", "margin-left: 20px");
                        }

                        $("#sorts3").val(data.data.categoryBrandMarge[2].sequence)
                        $("#brandname3").val(data.data.categoryBrandMarge[2].brandName)
                        $("#brandname3").text(data.data.categoryBrandMarge[2].brandId)

                        if (data.data.categoryBrandMarge[2].brandPictureUrl != "" || data.data.categoryBrandMarge[2].brandPictureUrl != undefined) {
                            $("#uu3").html("<img id='licencepicpath3' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[2].brandPictureUrl + "'>")
                            $("#uploads3").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads3').removeAttr('onclick');
                            $('#deletes3').attr('onclick', 'deletes(3)');
                            $("#deletes3").removeAttr("style");
                        } else {
                            $("#licencepicpath3").remove();
                            $("#deletes3").attr("style", "opacity: 0.2");
                            $('#deletes3').removeAttr('onclick');
                            $('#uploads3').removeAttr("style");
                            $('#uploads3').attr("onclick", "addBtn(this,1)");
                            $('#uploads3').attr("style", "margin-left: 20px");
                        }

                        $("#sorts4").val(data.data.categoryBrandMarge[3].sequence)
                        $("#brandname4").val(data.data.categoryBrandMarge[3].brandName)
                        $("#brandname4").text(data.data.categoryBrandMarge[3].brandId)
                        if (data.data.categoryBrandMarge[3].brandPictureUrl != "" || data.data.categoryBrandMarge[3].brandPictureUrl != undefined) {

                            $("#uu4").html("<img id='licencepicpath4' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[3].brandPictureUrl + "'>")
                            $("#uploads4").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads4').removeAttr('onclick');
                            $('#deletes4').attr('onclick', 'deletes(4)');
                            $("#deletes4").removeAttr("style");
                        } else {
                            $("#licencepicpath4").remove();
                            $("#deletes4").attr("style", "opacity: 0.2");
                            $('#deletes4').removeAttr('onclick');
                            $('#uploads4').removeAttr("style");
                            $('#uploads4').attr("onclick", "addBtn(this,1)");
                            $('#uploads4').attr("style", "margin-left: 20px");
                        }


                        $("#sorts5").val(data.data.categoryBrandMarge[4].sequence)
                        $("#brandname5").val(data.data.categoryBrandMarge[4].brandName)
                        $("#brandname5").text(data.data.categoryBrandMarge[4].brandId)
                        if (data.data.categoryBrandMarge[4].brandPictureUrl != "" || data.data.categoryBrandMarge[4].brandPictureUrl != undefined) {

                            $("#uu5").html("<img id='licencepicpath5' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[4].brandPictureUrl + "'>")
                            $("#uploads5").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads5').removeAttr('onclick');
                            $('#deletes5').attr('onclick', 'deletes(5)');
                            $("#deletes5").removeAttr("style");
                        } else {
                            $("#licencepicpath5").remove();
                            $("#deletes5").attr("style", "opacity: 0.2");
                            $('#deletes5').removeAttr('onclick');
                            $('#uploads5').removeAttr("style");
                            $('#uploads5').attr("onclick", "addBtn(this,1)");
                            $('#uploads5').attr("style", "margin-left: 20px");
                        }

                        $("#sorts6").val(data.data.categoryBrandMarge[5].sequence)
                        $("#brandname6").val(data.data.categoryBrandMarge[5].brandName)
                        $("#brandname6").text(data.data.categoryBrandMarge[5].brandId)
                        if (data.data.categoryBrandMarge[5].brandPictureUrl != "" || data.data.categoryBrandMarge[5].brandPictureUrl != undefined) {

                            $("#uu6").html("<img id='licencepicpath6' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[5].brandPictureUrl + "'>")
                            $("#uploads6").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads6').removeAttr('onclick');
                            $('#deletes6').attr('onclick', 'deletes(6)');
                            $("#deletes6").removeAttr("style");
                        } else {
                            $("#licencepicpath6").remove();
                            $("#deletes6").attr("style", "opacity: 0.2");
                            $('#deletes6').removeAttr('onclick');
                            $('#uploads6').removeAttr("style");
                            $('#uploads6').attr("onclick", "addBtn(this,1)");
                            $('#uploads6').attr("style", "margin-left: 20px");
                        }
                        $("#sorts7").val(data.data.categoryBrandMarge[6].sequence)
                        $("#brandname7").val(data.data.categoryBrandMarge[6].brandName)
                        $("#brandname7").text(data.data.categoryBrandMarge[6].brandId)
                        if (data.data.categoryBrandMarge[6].brandPictureUrl != "" || data.data.categoryBrandMarge[6].brandPictureUrl != undefined) {

                            $("#uu7").html("<img id='licencepicpath7' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[6].brandPictureUrl + "'>")
                            $("#uploads7").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads7').removeAttr('onclick');
                            $('#deletes7').attr('onclick', 'deletes(7)');
                            $("#deletes7").removeAttr("style");
                        } else {
                            $("#licencepicpath7").remove();
                            $("#deletes7").attr("style", "opacity: 0.2");
                            $('#deletes7').removeAttr('onclick');
                            $('#uploads7').removeAttr("style");
                            $('#uploads7').attr("onclick", "addBtn(this,1)");
                            $('#uploads7').attr("style", "margin-left: 20px");
                        }

                        $("#sorts8").val(data.data.categoryBrandMarge[7].sequence)
                        $("#brandname8").val(data.data.categoryBrandMarge[7].brandName)
                        $("#brandname8").text(data.data.categoryBrandMarge[7].brandId)
                        if (data.data.categoryBrandMarge[7].brandPictureUrl != "" || data.data.categoryBrandMarge[7].brandPictureUrl != undefined) {

                            $("#uu8").html("<img id='licencepicpath8' style='width:95px;height:25px;' src='" + data.data.categoryBrandMarge[7].brandPictureUrl + "'>")
                            $("#uploads8").attr("style", "opacity: 0.2;margin-left: 20px");
                            $('#uploads8').removeAttr('onclick');
                            $('#deletes8').attr('onclick', 'deletes(8)');
                            $("#deletes8").removeAttr("style");
                        } else {
                            $("#licencepicpath8").remove();
                            $("#deletes8").attr("style", "opacity: 0.2");
                            $('#deletes8').removeAttr('onclick');
                            $('#uploads8').removeAttr("style");
                            $('#uploads8').attr("onclick", "addBtn(this,1)");
                            $('#uploads8').attr("style", "margin-left: 20px");
                        }
                    }
                }
            }
        })

}
//品类
categoryss("")
function categoryss(pp) {
    var platformss=""
    var warehousess=""
    console.log(pp)
    if(pp!=undefined && pp!=""){

        platformss=$("#pingtai").val()
        warehousess=$("#pinjgthai").val()

    }else {
        platformss=platformcc
        warehousess=pinjgthaicc
    }
    //初始化 省
    var user_data = {
        platform:platformss,
        warehouse:warehousess,
        source:10
    }
    var succCallBack = function (data, status, response) {
        if(data.errorCode == 0){
            var tab_data=data.data;
            var cer = '';
            if(tab_data == ''){
                cer = '<option value=""></option>'
                $("#geta").html(cer);
            }else{
                for(var i=0; i<tab_data.length; i++){
                    if (tab_data[i].display_content!=''){
                        cer += '<option value="'+tab_data[i].front_first_category_id+'">'+tab_data[i].display_content+'</option>'
                    }                }
                $("#geta").html(cer);
                $("#geta").val(frontCategoryIds)
            }
        }
    };
    web.doAjax(root.sroreinter.selectCatgoryIdAsPlatformWarehouse, 'post', user_data, succCallBack);
}
//填写品牌名称或id查数据
function pinpai(val) {
    $("#brandnamett"+val).val(10)
    if($("#brandname"+val).val()==""){
        $("#licencepicpath"+val).remove();
        $("#uploads"+val).attr("style","opacity: 0.2;margin-left: 20px");
        $('#uploads'+val).removeAttr('onclick');
        $("#deletes"+val).attr("style","opacity: 0.2");
        $('#deletes'+val).removeAttr('onclick');
    }
    var brandName = "";//用于存放输入的字符串
    var brandId=""
    var user_data = {
        "brandName":$("#brandname"+val).val(),
        "brandId":$("#brandname"+val).val(),
        "type":2
    }
    var succCallBack = function (data, status, response) {
        if(data.errorCode=="0"){

            var jsonObj =data.data;
            if(jsonObj==""||$("#brandname"+val).val()==""){
                $("#tuan"+val).html("<li>无数据</li> ");
                $("#licencepicpath"+val).remove();
                $('#uploads'+val).removeAttr("style");
                $('#uploads'+val).attr("onclick","addBtn(this,1)");
                $('#uploads'+val).attr("style","margin-left: 20px");
                $("#deletes"+val).attr("style","opacity: 0.2");
                $('#deletes'+val).removeAttr('onclick');
            }else {
                var optionstring = "";
                for (var  i= 0; i < jsonObj.length; i++) {
                    optionstring += "<li onclick='relation("+ jsonObj[i].brand_id+",\""+jsonObj[i].brand_name+"\","+val+")' data-align=\"" + jsonObj[i].brand_id + "\" > " + jsonObj[i].brand_name + "</li>";
                }
                $("#tuan"+val).html(optionstring);
            }
        }else{
            $("#tuan"+val).html("<li>无数据</li> ");
        }
    };
    web.doAjax('https://'+ window.location.host +'/api/admin/aproduct/brand/getBrandWithSpuOnShelf', 'post', user_data, succCallBack);
}

//填写品牌名称或id查数据
function pinpaiii(val) {
    $("#brandnamett"+val).val(20)
    if($("#brandname"+val).val()==""){
        $("#licencepicpath"+val).remove();
        $("#uploads"+val).attr("style","opacity: 0.2;margin-left: 20px");
        $('#uploads'+val).removeAttr('onclick');
        $("#deletes"+val).attr("style","opacity: 0.2");
        $('#deletes'+val).removeAttr('onclick');
    }
    var brandName = "";//用于存放输入的字符串
    var brandId=""
    var user_data = {
        "brandName":$("#brandname"+val).val(),
        "brandId":$("#brandname"+val).val(),
        "type":2
    }
    var succCallBack = function (data, status, response) {
        if(data.errorCode=="0"){

            var jsonObj =data.data;
            if(jsonObj==""||$("#brandname"+val).val()==""){
                $("#tuan"+val).html("<li>无数据</li> ");
                $("#licencepicpath"+val).remove();
                $('#uploads'+val).removeAttr("style");
                $('#uploads'+val).attr("onclick","addBtn(this,1)");
                $('#uploads'+val).attr("style","margin-left: 20px");
                $("#deletes"+val).attr("style","opacity: 0.2");
                $('#deletes'+val).removeAttr('onclick');
            }else {
                var optionstring = "";
                for (var  i= 0; i < jsonObj.length; i++) {
                    optionstring += "<li onclick='relation("+ jsonObj[i].brand_id+",\""+jsonObj[i].brand_name+"\","+val+")' data-align=\"" + jsonObj[i].brand_id + "\" > " + jsonObj[i].brand_name + "</li>";
                }
                $("#tuan"+val).html(optionstring);
            }
        }else{
            $("#tuan"+val).html("<li>无数据</li> ");
        }
    }
    web.doAjax('https://'+ window.location.host +'/api/admin/aproduct/brand/getBrandWithSpuOnShelf', 'post', user_data, succCallBack);
}
//取光标
$("#brandname1").focus(function () {
    $("#tuan1").show()
});
$(document).bind("click", function (e) {
    //id为menu的是菜单，id为open的是打开菜单的按钮
    if ($(e.target).closest("#tuan1").length == 0 && $(e.target).closest("#brandname1").length == 0) {
        //点击id为menu之外且id不是不是open，则触发
        $("#tuan1").hide()
    }
})
$("#brandname2").focus(function () {
    $("#tuan2").show()
});
$(document).bind("click", function (e) {
    //id为menu的是菜单，id为open的是打开菜单的按钮
    if ($(e.target).closest("#tuan2").length == 0 && $(e.target).closest("#brandname2").length == 0) {
        //点击id为menu之外且id不是不是open，则触发
        $("#tuan2").hide()
    }
})
$("#brandname3").focus(function () {
    $("#tuan3").show()
});
$(document).bind("click", function (e) {
    //id为menu的是菜单，id为open的是打开菜单的按钮
    if ($(e.target).closest("#tuan3").length == 0 && $(e.target).closest("#brandname3").length == 0) {
        //点击id为menu之外且id不是不是open，则触发
        $("#tuan3").hide()
    }
})
$("#brandname4").focus(function () {
    $("#tuan4").show()
});
$(document).bind("click", function (e) {
    //id为menu的是菜单，id为open的是打开菜单的按钮
    if ($(e.target).closest("#tuan4").length == 0 && $(e.target).closest("#brandname4").length == 0) {
        //点击id为menu之外且id不是不是open，则触发
        $("#tuan4").hide()
    }
})
$("#brandname5").focus(function () {
    $("#tuan5").show()
});
$(document).bind("click", function (e) {
    //id为menu的是菜单，id为open的是打开菜单的按钮
    if ($(e.target).closest("#tuan5").length == 0 && $(e.target).closest("#brandname5").length == 0) {
        //点击id为menu之外且id不是不是open，则触发
        $("#tuan5").hide()
    }
})
$("#brandname6").focus(function () {
    $("#tuan6").show()
});
$(document).bind("click", function (e) {
    //id为menu的是菜单，id为open的是打开菜单的按钮
    if ($(e.target).closest("#tuan6").length == 0 && $(e.target).closest("#brandname6").length == 0) {
        //点击id为menu之外且id不是不是open，则触发
        $("#tuan6").hide()
    }
})

$("#brandname7").focus(function () {
    $("#tuan7").show()
});
$(document).bind("click", function (e) {
    //id为menu的是菜单，id为open的是打开菜单的按钮
    if ($(e.target).closest("#tuan7").length == 0 && $(e.target).closest("#brandname7").length == 0) {
        //点击id为menu之外且id不是不是open，则触发
        $("#tuan7").hide()
    }
})

$("#brandname8").focus(function () {
    $("#tuan8").show()
});
$(document).bind("click", function (e) {
    //id为menu的是菜单，id为open的是打开菜单的按钮
    if ($(e.target).closest("#tuan8").length == 0 && $(e.target).closest("#brandname8").length == 0) {
        //点击id为menu之外且id不是不是open，则触发
        $("#tuan8").hide()
    }
})

function relation(id,ce,val) {
    $("#brandname"+val).val(ce).text(id)
    $("#tuan"+val).hide()
    $("#brandnamett"+val).val(20)
//获取图片
    var user_data = {
        "brandName":$("#brandname"+val).val(),
        "brandId":$("#brandname"+val).val(),
        "type":2
    }
    var succCallBack = function (data, status, response) {
        if(data.errorCode=="0"){
            for(var i = 0; i < data.data.length; i++) {
                if (data.data[i].logo!="" && data.data[i].logo!=null) {
                    if($("#brandname"+val).val()==data.data[i].brand_name){
                        $("#uu"+val).html("<img id='licencepicpath"+val+"' name='lskd' style='width:95px;height:25px;' src='"+data.data[i].logo+"'>")
                        $("#uploads"+val).attr("style","opacity: 0.2;margin-left: 20px");
                        $('#uploads'+val).removeAttr('onclick');
                        $('#deletes'+val).attr('onclick','deletes('+val+')');
                        $("#deletes"+val).removeAttr("style");
                    }
                }else {
                    $("#deletes"+val).attr("style","opacity: 0.2");
                    $('#deletes'+val).removeAttr('onclick');
                    $('#uploads'+val).removeAttr("style");
                    $('#uploads'+val).attr("onclick","addBtn(this,1)");
                    $('#uploads'+val).attr("style","margin-left: 20px");
                    $("#licencepicpath"+val).remove();
                }
            }
        }
    }
    web.doAjax('https://'+ window.location.host +'/api/admin/aproduct/brand/getBrandWithSpuOnShelf', 'post', user_data, succCallBack);
}

//点击事件
var ipcuu=""
function addBtn(cen,ir) {
    ipcuu=ir
    $(cen).prev().trigger('click');
}
//图片上传
var formData
function changImg(event,val){
    var image = new Image();
    for (var i = 0; i < event.target.files.length; i++) {
        var file = event.target.files.item(i);
        if (!(/^image\/.*$/i.test(file.type))) {
            layer.msg('请上传图片!', {icon: 6, time: 2000});
            continue; //不是图片 就跳出这一次循环
        }
        //实例化FileReader API
        var freader = new FileReader();
        freader.readAsDataURL(file);
        freader.onload = function (event) {
            image.src = event.target.result;
            image.onload = function () {
                if (file.size > 15 * 1024 * 1024) {
                    layer.msg('图片不得大于15M!', {icon: 6, time: 2000});
                    $("#file+val").val("")
                    return;
                } else {
                    var element = $(event.target).next();
                    if (this.width != 95 || this.height != 30) {
                        layer.msg('图片大小限制为95*30!', {icon: 6, time: 2000});
                        r = 1
                        $("#file+val").val("")
                        return;
                    } else {
                        $("#uu+val").html("<img id='licencepicpath"+val+"' style='width:95px;height:25px;' src='" + event.target.result + "'>")

                        formData = new FormData();
                        formData.append('file', $("#file"+val)[0].files[0]);
                        $.ajax({
                            url: root.inter.imgUpload,
                            cache: false, //禁用缓存
                            type: "POST",
                            processData: false,
                            // 告诉jQuery不要去设置Content-Type请求头
                            contentType: false,
                            data: formData,
                            success: function (data) {
                                pageData = data;
                                $("#uu"+val).html("<img id='licencepicpath"+val+"' style='width:95px;height:25px;' src='"+data[0].fullPath+"'>")
                                $('#deletes'+val).attr('onclick','deletes('+val+')');
                                $("#deletes"+val).removeAttr("style");
                                $("#uploads"+val).attr("style","opacity: 0.2;margin-left: 20px");
                                $('#uploads'+val).removeAttr('onclick');
                            },
                            error: function () {
                                $.Huimodalalert('失败！', 2000);
                            }
                        })
                    }
                }
            }
        }
    }


}

//删除
function deletes(i) {
    $('#file'+i).val('');
    $("#licencepicpath"+i).remove();
    $('#uploads'+i).removeAttr("style");
    $('#uploads'+i).attr("onclick","addBtn(this,1)");
    $('#uploads'+i).attr("style","margin-left: 20px");
    $("#deletes"+i).attr("style","opacity: 0.2");
    $('#deletes'+i).removeAttr('onclick');
}

//保存
function categoryadd() {
    if($("#brandnamett1").val()==10){
        $("#brandname1").val("")
        $("#licencepicpath1").remove();
        $('#file1').val('');
        $("#uploads1").attr("style","opacity: 0.2;margin-left: 20px");
        $('#uploads1').removeAttr('onclick');
        $("#deletes1").attr("style","opacity: 0.2");
        $('#deletes1').removeAttr('onclick');
    }
    if($("#brandnamett2").val()==10){
        $("#brandname2").val("")
        $("#licencepicpath2").remove();
        $('#file2').val('');
        $("#uploads2").attr("style","opacity: 0.2;margin-left: 20px");
        $('#uploads2').removeAttr('onclick');
        $("#deletes2").attr("style","opacity: 0.2");
        $('#deletes2').removeAttr('onclick');
    }
    if($("#brandnamett3").val()==10){
        $("#brandname3").val("")
        $("#licencepicpath3").remove();
        $('#file3').val('');
        $("#uploads3").attr("style","opacity: 0.2;margin-left: 20px");
        $('#uploads3').removeAttr('onclick');
        $("#deletes3").attr("style","opacity: 0.2");
        $('#deletes3').removeAttr('onclick');
    }
    if($("#brandnamett4").val()==10){
        $("#brandname4").val("")
        $("#licencepicpath4").remove();
        $('#file4').val('');
        $("#uploads4").attr("style","opacity: 0.2;margin-left: 20px");
        $('#uploads4').removeAttr('onclick');
        $("#deletes4").attr("style","opacity: 0.2");
        $('#deletes4').removeAttr('onclick');
    }
    if($("#brandnamett5").val()==10){
        $("#brandname5").val("")
        $("#licencepicpath5").remove();
        $('#file5').val('');
        $("#uploads5").attr("style","opacity: 0.2;margin-left: 20px");
        $('#uploads5').removeAttr('onclick');
        $("#deletes5").attr("style","opacity: 0.2");
        $('#deletes5').removeAttr('onclick');
    }
    if($("#brandnamett6").val()==10){
        $("#brandname6").val("")
        $("#licencepicpath6").remove();
        $('#file6').val('');
        $("#uploads6").attr("style","opacity: 0.2;margin-left: 20px");
        $('#uploads6').removeAttr('onclick');
        $("#deletes6").attr("style","opacity: 0.2");
        $('#deletes6').removeAttr('onclick');
    }
    if($("#brandnamett7").val()==10){
        $("#brandname7").val("")
        $("#licencepicpath7").remove();
        $('#file7').val('');
        $("#uploads7").attr("style","opacity: 0.2;margin-left: 20px");
        $('#uploads7').removeAttr('onclick');
        $("#deletes7").attr("style","opacity: 0.2");
        $('#deletes7').removeAttr('onclick');
    }if($("#brandnamett8").val()==10){
        $("#brandname8").val("")
        $("#licencepicpath8").remove();
        $('#file8').val('');
        $("#uploads8").attr("style","opacity: 0.2;margin-left: 20px");
        $('#uploads8').removeAttr('onclick');
        $("#deletes8").attr("style","opacity: 0.2");
        $('#deletes8').removeAttr('onclick');
    }
    if($("#title").val()==""){
        $.Huimodalalert('请输入标题！',2000);
        return false;
    }
    if($("#logmin").val()==""){
        $.Huimodalalert('请输入时间！',2000);
        return false;
    }
    var objArr=[];
    let brandslength = $("input[name='brandne3']")
    let sequencelength = $("input[name='s1']")
    let imgsfghlength = $("img")
    var idcarr=""
    var idsss=cardata.data.categoryBrandMarge
    for (let i=0;i<brandslength.length;i++) {
        let sequece = $(sequencelength[i]).val()
        let name = $(brandslength[i]).val();
        if(name==""||$(imgsfghlength[i]).attr("src")==undefined){
            $.Huimodalalert('请配置八组资源位内容！',2000);
            return false;
        }
        if($(sequencelength[i]).val()==""){
            $.Huimodalalert('请为上传的品类logo排序！',2000);
            return false;
        }

        if ("" != name && null != name ||"" != sequece && null != sequece) {
            var categoryid= getQueryString('categoryid')
            objArr.push({
                "brandId": $(brandslength[i]).text(),
                "brandName": $(brandslength[i]).val(),
                "brandPictureUrl":$(imgsfghlength[i]).attr("src"),
                "sequence":$(sequencelength[i]).val(),
                "id":idsss[i].id
            });
        }
    }
    var categoryid= getQueryString('categoryid')
    var catelogo={
        "categoryId":"21",
        "platform":$("#pingtai").val(),
        "warehouseCode":$("#pinjgthai").val(),
        "warehouseName":$("#pinjgthai option:selected").text(),
        "frontCategoryId":$("#geta").val(),
        "title":$("#title").val(),
        "releaseTime":$("#logmin").val(),
        "createdTime":createdTimeml,
        "createdBy":createdBymmk,
        "createdName":createdNamemmk,
        "id":categoryid
    }

    $.ajax({
        url:root.sroreinter.addCategoryBrandLogo,
        cache: false,  //禁用缓存
        type: "POST",
        dataType:'json',
        contentType: "application/json",
        data: JSON.stringify({
            "categoryBrandLogo":catelogo,
            "categoryBrandMarge":objArr
        }),
        success: function (data) {
            if(data.errorCode==0){
                $.Huimodalalert('成功！',2000);
                parent.isEdit = true;
                setTimeout(fanhui,2000)
            }else {
                $.Huimodalalert(data.msg,2000);

            }
        },
        error: function () {
            $.Huimodalalert('失败！',2000);
        }
    })
}
//跳转父页面
function fanhui(){
    window.parent.conter();
    var index = parent.layer.getFrameIndex(window.name);
    parent.layer.close(index);
}
//时间
Date.prototype.Format = function (fmt) { //author: meizz
    var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //日
        "h+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds(), //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}

var fortyContent;

//限制字符
var len
var Preser
var common=40//要限制输入的字数
$('#commonText').text('('+common+')')
function checkMaxIut(me) {
    var text=$(me).val()
    strlen(text)
    if(len>common){
        $(me).val(Preser)
    }else {
        Preser=$(me).val()
    }
}
function strlen(str){
    len = 0;
    for (var i=0; i<str.length; i++) {
        var c = str.charCodeAt(i);
        //单字节加1
        if ((c >= 0x0001 && c <= 0x007e) || (0xff60<=c && c<=0xff9f)) {
            len++;
        } else {
            len+=2;
        }
    }
    $('#textSpan').text((len>40)?40:len)
    return len;
}